package com.demo;


import com.demo.singleton.*;
import com.demo.strategy.st_02.ContextHandle;
import com.demo.strategy.st_02.MJCouponDiscount;
import com.demo.strategy.st_02.ZJCouponDiscount;

import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws InterruptedException {

        /************************01-单例模式****************************/
        //单例不能new
        //new Singleton_01()
        //单线程
        //Singleton_01 singleton01 = Singleton_01.getInstance();
        //多线程下生成多个实例
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                //Singleton_01 singleton01 = Singleton_01.getInstance();
                //Singleton_02 singleton02 = Singleton_02.getInstance();
                //Singleton_03 singleton03 = Singleton_03.getInstance();
                //Singleton_04 singleton04 = Singleton_04.getInstance();
                //Singleton_05 singleton05 = Singleton_05.getInstance();
                //Singleton_06 singleton06 = Singleton_06.getInstance();  //没验证出来
                //Singleton_06 singleton06_01 = Singleton_06.getInstance();  //没验证出来
                // System.out.println(singleton06 == singleton06_01);
                //Singleton_07 singleton07 = Singleton_07.INSTANCE;
                //Singleton_07 singleton08 = Singleton_07.INSTANCE;
                //System.out.println(singleton07 == singleton08);
            }, String.valueOf(i)).start();
        }

        /**********************策略模式******************************/
        // 直减；100-10，商品100元
       /* ContextHandle<Double> context = new ContextHandle<Double>(new ZJCouponDiscount());
        BigDecimal discountAmount = context.discountAmount(10D, new BigDecimal(100));
        System.out.println("测试结果：直减优惠后⾦额:" + discountAmount);*/

        // 满100减10，商品100元
       /* ContextHandle<Map<String,String>> context = new ContextHandle<Map<String,String>>
                (new MJCouponDiscount());
        Map<String,String> mapReq = new HashMap<String, String>();
        mapReq.put("x","100");
        mapReq.put("n","10");
        BigDecimal discountAmount = context.discountAmount(mapReq, new BigDecimal(100));
        System.out.println("测试结果：直减优惠后⾦额:" + discountAmount);*/

        // Scanner input=new Scanner(System.in);
        // String str=input.next();
        //System.out.println("hello world");




    }
}
